package com.zry.retorfit.ui;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;



import com.zry.retorfit.R;
import com.zry.retorfit.retrofit.ApiSupport;
import com.zry.retorfit.retrofit.BaseApiRetrofit;

import java.util.HashMap;

public class TestActivity extends AppCompatActivity implements ApiSupport {
	private TextView testTV;
	private TextView testTV01;
	private TextView testTV02;
	private TextView testTV03;
	
	@RequiresApi(api = Build.VERSION_CODES.N)
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test);
		testTV = findViewById(R.id.testTV);
		testTV01 = findViewById(R.id.testTV01);
		testTV02 = findViewById(R.id.testTV02);
		testTV03 = findViewById(R.id.testTV03);
		
		initData();
	}
	
	
	@RequiresApi(api = Build.VERSION_CODES.N)
	private void initData() {

		execute(getApi().getCameraList("3AVh4Fy9vmAzAHTVAxRxW4"),
			response -> {
				testTV.setText(response.toString());
				testTV01.setText(response.getMsg());
				testTV02.setText(response.getData().get(0).toString());
				testTV03.setText(response.getData().get(1).toString());
			});
		
//		get(BaseApiRetrofit.BASE_URL + "api/mp/videoActionAPI/getCominfDevBycomID" +
//			    ".htm?comId=3AVh4Fy9vmAzAHTVAxRxW4", response -> {
//				runOnUiThread(() -> testTV.setText(response));
//			}
//		);
		
//		HashMap<String, String> params = new HashMap<>();
//		params.put("comId", "3AVh4Fy9vmAzAHTVAxRxW4");
//
//		post(BaseApiRetrofit.BASE_URL + "api/mp/videoActionAPI/getCominfDevBycomID.htm?", params,
//			response -> runOnUiThread(() -> testTV.setText(response)));
	}
}
